package com.hehua.CommandPatternQueue;

import java.util.ArrayList;

public class CommandQueue {
    /**
     * 定义一个ArrayList来储存命令队列
     */
    private ArrayList<Command> commands = new ArrayList<>();

    public void addCommand(Command command){
        commands.add(command);
    }
    public void removeCommand(Command command){
        commands.remove(command);
    }

    /**
     * 循环调用每一个命令对象execute()方法
     */
    public void execute(){
        for (Command command : commands) {
            command.execute();
        }
    }
}
